/**
 *
 */
package com.storm.lib.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


import org.apache.log4j.Logger;

import com.storm.lib.base.BasePo;


/**
 * 类功能: HashMap基类
 * @author johnny
 * @version 2010-10-29
 */
public class HashMapUtil {
	protected final static Logger logger = Logger.getLogger(HashMapUtil.class);
	/**
	 *
	 * 方法功能:依次打印hashMap
	 * 更新时间:2010-10-29, 作者:johnny
	 * @param map
	 */
	public static void iterratorPrintMap(HashMap<String, Object> map){
		Iterator iter = map.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry entry = (Map.Entry) iter.next();
			String key = (String) entry.getKey();
			String val = entry.getValue().toString();
			logger.debug("key = "+key+",value = "+val);
		}
	}

	/**
	 * 方法功能:返回HashMap
	 * 更新时间:2010-12-28, 作者:johnny
	 * @param list
	 * @return
	 */
	public static ConcurrentHashMap getHashMapFromList(List<BasePo> list) {
		ConcurrentHashMap<String, BasePo> map = new ConcurrentHashMap<String, BasePo>();
		for (int i = 0; i < list.size(); i++) {
			map.put(list.get(i).getId().toString(), list.get(i));
		}
		return map;
	}
}
